<template>
  <div class="comment-wrapper">
    <div class="comment-avatar">
      <slot name="avatar">
        <div class="default-avatar">{{ avatarText }}</div>
      </slot>
    </div>
    <div class="comment-content">
      <div class="comment-header">
        <slot name="author">
          <span class="comment-author">{{ author }}</span>
        </slot>
      </div>
      <div class="comment-body">
        <slot name="content">
          <div class="comment-text">{{ content }}</div>
        </slot>
      </div>
    </div>
  </div>
</template>

<script setup lang="jsx">
import { computed } from 'vue'

// 定义组件属性
const props = defineProps({
  author: {
    type: String,
    default: ''
  },
  content: {
    type: String,
    default: ''
  },
  avatarText: {
    type: String,
    default: '用户'
  }
})
</script>

<style scoped lang="scss">
.comment-wrapper {
  display: flex;
  padding: 12px 0;
  gap: 12px;
  align-items: flex-start;
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #165dff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

.default-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: #165dff;
  color: white;
  font-size: 14px;
  font-weight: 500;
}

.comment-content {
  flex: 1;
  min-width: 0;
}

.comment-header {
  margin-bottom: 4px;
}

.comment-author {
  font-weight: 500;
  color: #1d2129;
  font-size: 14px;
}

.comment-body {
  font-size: 14px;
  color: #4e5969;
  line-height: 1.6;
  word-break: break-word;
}

.comment-text {
  margin: 0;
}
</style>